package org.infodavid.common.persistence;

import javax.persistence.PersistenceException;

/**
 * The Interface IDatabaseSchema.
 */
public interface IDatabaseSchema extends IDataObject<Long>, INamed, ICommented {

  enum ESchemaStatus {
    AVAILABLE, BUILD, MAINTENANCE
  }

  /** The ID property. */
  String ID = "schemaKey";

  /** The USER property. */
  String USERNAME = "user";

  /** The PASSWORD property. */
  String PASSWORD = "password";

  /** The JNDI_NAME property. */
  String JNDI_NAME = "jndiName";

  /** The HOST property. */
  String HOST = "host";

  /** The constant MAX_LENGTH_JNDI_NAME. */
  int MAX_LENGTH_JNDI_NAME = 255;

  /** The constant MAX_LENGTH_PASSWORD. */
  int MAX_LENGTH_PASSWORD = 16;

  /** The constant MAX_LENGTH_USERNAME. */
  int MAX_LENGTH_USERNAME = 128;

  /** The DB_SCHEMA property. */
  String DB_SCHEMA = "schema";

  /** The STATUS property. */
  String STATUS = "status";

  /**
   * Gets the database host.
   * @return the host
   */
  IDatabaseHost getHost();

  /**
   * Gets the JNDI name.
   * @return the JNDI name
   */
  String getJndiName();

  /**
   * Gets the user.
   * @return the user
   */
  String getUsername();

  /**
   * Gets the password.
   * @return the password
   */
  String getPassword();

  /**
   * Sets the database host.
   * @param value the host
   */
  void setHost(IDatabaseHost value);

  /**
   * Sets the JNDI name.
   * @param value the JNDI name
   */
  void setJndiName(String value);

  /**
   * Gets the user.
   * @param value the value
   */
  void setUsername(String value);

  /**
   * Sets the password.
   * @param value the value
   */
  void setPassword(String value);

  /**
   * Gets the connection configuration associated to this database schema.
   * @return the configuration object or null
   */
  IConnectionConfiguration toConnectionConfiguration() throws PersistenceException;

  /**
   * Gets the status.
   * @return the status
   */
  ESchemaStatus getStatus();

  /**
   * Sets the status.
   * @param status the status
   */
  void setStatus(ESchemaStatus value);
}
